import request from '@/utils/request'

// 登录方法
export function login(browserIp, userName, password, status) {
	const data = {
		"browserIp": browserIp,
		"userName": userName,
		"password": password,
		"status": status
	}
	var jmdata = JSON.stringify(data);
	jmdata = jmdata.myReplace("{", "%7B").myReplace("}", "%7D").myReplace("\"", "%22");
	return request({
		'url': '/system/v9/login/checkUser?data=' + jmdata,
		headers: {
			isToken: false
		},
		'method': 'post'
	})
}

String.prototype.myReplace = function(f, e) { //吧f替换成e
	var reg = new RegExp(f, "g"); //创建正则RegExp对象   
	return this.replace(reg, e);
}

// 获取用户详细信息
export function getInfo() {
	return request({
		'url': '/getInfo',
		'method': 'get'
	})
}

// 退出方法
export function logout() {
	return request({
		'url': '/system/v9/login/logout',
		'method': 'get'
	})
}

//刷新refreshToken
export function refreshToken(configId) {
	return request({
		url: '/system/v9/token/refreshToken',
		method: 'get',
	})
}